<?php

namespace IMT\EventBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * This is the class that validates and merges configuration from your app/config files
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
 */
class Configuration implements ConfigurationInterface
{
	private $eventTypes = array('event', 'tak');
	
    /**
     * {@inheritDoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('imt_event');
        
        //$rootNode;
        
        $this->addEventSection($rootNode);
        $this->addTaskSection($rootNode);

        return $treeBuilder;
    }
    
    private function addEventSection(ArrayNodeDefinition $node){
    	$node
	    	->children()
		    	->arrayNode('event')
			    	->children()
				    	->booleanNode('enabled')
				    		->isRequired()
				    	->end()
				    	->scalarNode('event_class')
				    		->isRequired()
				    	->end()
				    	->scalarNode('manager_class')
				    		->isRequired()
				    	->end()
				    	->scalarNode('webservice')
				    		->isRequired()
				    	->end()
				    ->end()
		    	->end()
			->end();
    }
    
    private function addTaskSection(ArrayNodeDefinition $node){
    	$node
	    	->children()
		    	->arrayNode('task')
			    	->children()
				    	->booleanNode('enabled')
				    		->isRequired()
				    	->end()
				    	->scalarNode('event_class')
				    		->isRequired()
				    	->end()
				    	->scalarNode('manager_class')
				    		->isRequired()
				    	->end()
			    	->end()
		    	->end()
	    	->end();
    }
}
